Visual Basic 6 comes with a new designer that gives you the ability to create database reports without having to use any third-party tools to design and distribute the reports with the application. The Data Report Designer gives you the ability to create a database report that can be used by your application. The Data Report Designer offers several features that give you an easy way to design the report and give the user the ability to print and/or export the report data. These features are as follows:
Drag-and-Drop Field PlacementYou can drag and drop the fields needed from the Data Environment into the Data Report Designer. Visual Basic will automatically create a text box control on the Data Report and set the DataMember and DataField properties of the field.
Toolbox ControlsThe Data Report Designer has its own set of controls that are automatically added to the toolbox on their own tab, named DataReport.
Print PreviewThe user can preview the report in its own form window before printing it.
Print ReportsThe report can be printed in code using the PrintReport method or by clicking the Print button on the toolbar when in Preview mode.
File ExportThe report can also be exported in either HTML, text, or Unicode formats using the ExportReport method.
Using the Data Report Designer requires that you define a database connection and then design the actual report. To see how to use the Data Report in your application, you will start by building a simple report and then adding more advanced features to it, such as formulas and totals. Finally, you will see how to display this report from within your application.
Note If you have been using Visual Basic with Crystal Reports (see Day 13), don't panic. Crystal Reports is still included on the Visual Basic product CD-ROM. However, as the Data Report Designer is enhanced with more functionality, Crystal Reports will probably be removed altogether.
Creating the Report
The Data Report you create will use the Customers and Oruders commands that you previously defined in the Data Environment. These two commands combine to create a hierarchical query for the Data Report to use. When you have the commands defined and